﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;

namespace WebLayer
{
    public static class ConnectionClass
    {

        private static SqlConnection con;
        private static SqlCommand cmd;

        static ConnectionClass()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["dmaa0913_5ConnectionString"].ToString();
            con = new SqlConnection(connectionString);
            cmd = new SqlCommand("", con);
        }

        public static ArrayList GetCustomerByName(string name)
        {
            ArrayList list = new ArrayList();
            string query = string.Format("SELECT * FROM customer WHERE name LIKE '{0}'", name);

            try
            {
                con.Open();
                cmd.CommandText = query;
                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    int ssn = reader.GetInt32(0);
                    int creditNo = reader.GetInt32(1);
                    string fname = reader.GetString(2);
                    string street = reader.GetString(3);
                    int house = reader.GetInt32(4);
                    string city = reader.GetString(5);
                    int ZipCode = reader.GetInt32(6);
                    int phone = reader.GetInt32(7);
                    string email = reader.GetString(8);
                    string pass = reader.GetString(9);

                    //Customer customer = new Customer();

                }
            }
            finally
            {
                con.Close();
            }

            return list;
        }

    }
}